import com.alibaba.druid.pool.DruidDataSource;
import com.itheima.dao.UserDao;
import com.itheima.services.UserServices;
import javafx.application.Application;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.stereotype.Controller;

import java.sql.Connection;
import java.sql.SQLException;


public class DemoApplication {
    public static void main(String[] args) {
        ApplicationContext applicationContext = new ClassPathXmlApplicationContext("applicationContext.xml");
        UserServices userServices =(UserServices) applicationContext.getBean("userService");
        System.out.println(userServices);

        UserDao userDao = (UserDao) applicationContext.getBean("userDao");
        System.out.println(userDao);

        DruidDataSource  dateSource = new DruidDataSource();
        dateSource.setDriverClassName("com.mysql.jdbc.Driver");
        dateSource.setUrl("jdbc:mysql://localhost:3306/test");
        dateSource.setUsername("root");
        dateSource.setPassword("root");
        try {
            Connection connection =dateSource.getConnection();
            System.out.println(connection);
        }catch (SQLException e){
            e.printStackTrace();
        }
        DruidDataSource dataSource2 = (DruidDataSource) applicationContext.getBean("dataSource");

    }
}
